title: Wireworld in Emacs
date: 2017-03-10 17:01
author: Christine Lemmer-Webber
tags: emacs, wireworld, foss
slug: wireworld-in-emacs
---
<p>
  It is a truth universally acknowledged, that a hacker under the pressure
  of a deadline must be in want of a distraction.
  So it has been with me; I've a TODO list a mountain high, and I've been
  especially cracking under the stress of trying to get things moving along
  with <a href="https://www.w3.org/TR/activitypub/">ActivityPub</a>.
  I have a test suite to write, and it's turned out to be very hard,
  and this after several other deadlines in a row.
  I've also meant to blog about several things; say the talks I gave
  <a href="https://fosdem.org/2017/schedule/event/networkfreedom/">at
    FOSDEM</a> or
  <a href="https://archive.org/details/feb_2017-live_network_coding_8sync">
    at ChicagoLUG</a>.
  I've got a leak in my inbox that's been running for so long that the
  basement of my email has developed an undertow.
  So today, instead of getting what I knew I should be doing done,
  I instead went off and did something much more interesting, which
  is to say, I
  <a href="https://gitlab.com/dustyweb/wireworld-el">implemented
    Wireworld in emacs</a>.
</p>

<p class="centered">
  <img src="http://dustycloud.org/misc/emacs-wireworld.png" alt="Wireworld in emacs screenshot" />
</p>

<p>
  What is <a href="https://en.wikipedia.org/wiki/Wireworld">Wireworld</a>?
  It's a
  <a href="https://en.wikipedia.org/wiki/Cellular_automaton">cellular automaton</a>,
  not unlike
  <a href="https://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway's Game of Life</a>.
  Except with Wireworld, the "cells" in play are a bit more
  constrained... you have a set of wires, and electrons run along them,
  multiply, and die out, but the paths stay the same.
  The rules are very simple to implement
  (<a href="https://en.wikipedia.org/wiki/Wireworld#Rules">Wikipedia says
    all there is to know</a>).
  But you can build incredible things with it... even a
  <a href="https://www.quinapalus.com/wi-index.html">
    fully working computer</a>!
</p>

<p>
  Anyway, like many hacks, this one appeared out of boredom/distraction.
  I had long wanted to play with Wireworld, and I was reminded of it by
  <a href="https://codegolf.stackexchange.com/questions/88783/build-a-digital-clock-in-conways-game-of-life/">
    seeing this cool hack with a digital clock implemented in Conway's Game of Life</a>.
  It reminded me just how much I wanted to
  <a href="https://www.quinapalus.com/wi-index.html">
    try implementing that computer</a>,
  or even much simpler circuitry,
  but I had never been able to get started, because I couldn't find a
  working implementation that was easy for me to package.
  (I started packaging <a href="http://golly.sourceforge.net/">Golly</a>
  for <a href="https://www.gnu.org/software/guix/">Guix</a> but got stuck
  for reasons I can't remember.)
  I started thinking about how much I liked typing out ASCII art in Emacs,
  and how cool would it be to just "draw out" circuits in a buffer?
  I started experimenting... and within two hours, I had a working
  implementation!
  Two more hours later, I had a major mode with syntax highlighting
  and a handy C-c C-c keybinding for "advancing" the buffer.
  Live hacking in Emacs is amazing!
</p>

<p>
  More could be done.
  It would be nice to have a shortcut, say C-c C-s, that starts up a
  simulation in a new buffer and runs through the simulation automatically
  without clobbering your main buffer.
  (It could work the way M-x life does.)
  Anyway,
  <a href="https://gitlab.com/dustyweb/wireworld-el">the code is here</a>
  should you want to play around.
</p>

<p>
  Happy (circuit) hacking!
</p>
